<?php
App::import('Controller', 'Lil.LilPlugin');
/**
 * LilAdsPluginController class
 *
 * @uses          LilAdsPluginController
 * @package       lil_ads_plugin
 * @subpackage    lil_ads_plugin.controllers
 */
class LilAdsPluginController extends LilPluginController {
	var $name = 'LilAdsPlugin';
/**
 * initialize method
 *
 * This is a plugins initialization method
 *
 * @access public
 * @return void
 */
	function _initialize() {
		$this->attachHandler('admin_sidebar', '_setAdminSidebar');
	}
/**
 * _setAdminSidebar method
 *
 * Add admin sidebar elements.
 *
 * @param mixed $model
 * @access public
 * @return void
 */
	function _setAdminSidebar($controller, $sidebar) {
		$ads['visible'] = true;
		$ads['items'] = array(
			'ad_locations' => array(
				'visible' => true,
				'title' => __d('lil_ads', 'Locations', true),
				'url'   => array(
					'plugin'     => 'lil_ads',
					'controller' => 'locations',
					'action'     => 'index',
					'admin'      => true,
				),
				'params' => array(),
				'active' => in_array($this->params['controller'], array('locations')),
				'expand' => in_array($this->params['controller'], array('locations')),
				'submenu' => array(
					'edit' => array(
						'visible' => true,
						'title' => __d('lil_blogs', 'Edit', true),
						'url'   => array(
							'plugin'     => 'lil_ads',
							'controller' => 'locations',
							'action'     => 'index',
							'admin'      => true,
						),
						'params' => array(),
						'active' =>
							$this->params['controller'] == 'locations' &&
							in_array($this->params['action'], array('edit', 'index'))
					),
					'add' => array(
						'visible' => true,
						'title' => __d('lil_ads', 'Add New', true),
						'url'   => array(
							'plugin'     => 'lil_ads',
							'controller' => 'locations',
							'action'     => 'add',
							'admin'      => true,
						),
						'params' => array(),
						'active' =>
							($this->params['controller'] == 'locations') &&
							($this->params['action'] == 'add')
					),
				)
			),
			'ad_campaigns' => array(
				'visible' => true,
				'title' => __d('lil_ads', 'Campaigns', true),
				'url'   => array(
					'plugin'     => 'lil_ads',
					'controller' => 'campaigns',
					'action'     => 'index',
					'admin'      => true,
				),
				'params' => array(),
				'active' => in_array($this->params['controller'], array('campaigns', 'actions')),
				'expand' => in_array($this->params['controller'], array('campaigns', 'actions')),
				'submenu' => array(
					'edit' => array(
						'visible' => true,
						'title' => __d('lil_blogs', 'Edit', true),
						'url'   => array(
							'plugin'     => 'lil_ads',
							'controller' => 'campaigns',
							'action'     => 'index',
							'admin'      => true,
						),
						'params' => array(),
						'active' =>
							$this->params['controller'] == 'campaigns' &&
							in_array($this->params['action'], array('edit', 'index'))
					),
					'add' => array(
						'visible' => true,
						'title' => __d('lil_ads', 'Add New', true),
						'url'   => array(
							'plugin'     => 'lil_ads',
							'controller' => 'campaigns',
							'action'     => 'add',
							'admin'      => true,
						),
						'params' => array(),
						'active' =>
							($this->params['controller'] == 'campaigns') &&
							($this->params['action'] == 'add')
					),
					'stats' => array(
						'visible' => true,
						'title' => __d('lil_ads', 'Statistics', true),
						'url'   => array(
							'plugin'     => 'lil_ads',
							'controller' => 'campaigns',
							'action'     => 'stats',
							'admin'      => true,
						),
						'params' => array(),
						'active' =>
							(($this->params['controller'] == 'campaigns') &&	($this->params['action'] == 'stats')) ||
							(($this->params['controller'] == 'actions'))
					),
				)
			)
		);
		
		// insert into sidebar right after welcome panel
		$this->sidebarInsertPanel($sidebar, array('end' => true), array('ads' => $ads));
		
		return $sidebar;
	}
}
?>